<include file="Common:header" />
<import type='css' file="Script.Validator.css.validationEngine,Ueditor.third-party.SyntaxHighlighter.shCoreDefault" />
<div id="columns">
<div id="centercol">
    <div class="post_section">
      <div class="post_header_section">
        <div class="post_title"><a href="__APP__/Article/view/articleId/{$articleInfo.article_id}">{$articleInfo.title}</a></div>
        <div class="post_info">{$articleInfo.create_time} in
        <if condition="$articleInfo.type_id eq 0">
        <a target="_parent" href="__APP__/Article/index/typeId/0">默认分类</a> by&nbsp;
        <else/>
        <a target="_parent" href="__APP__/Article/index/typeId/{$articleInfo['type_info'].type_id}">{$articleInfo['type_info'].type_name}</a> by&nbsp;
        </if>
        <a target="_parent" href="__APP__/About">{$articleInfo.author}</a>
        </div>
        <div class="post_meta"></div>
      </div>
      <div class="post_content_section">
        {$articleInfo.content}
        <div class="margin_bottom_5"></div>
        <div class="post_bottom">
          <div class="tags">
          <foreach name="articleInfo.tag" item="tag">
          <a class="a_tag" href="__APP__/Article/index/tagId/{$tag.tag_id}"><span class="q_tag">#{$tag.tag_name}</span></a>
          </foreach>
          </div>
          <div class="link_button">
            <span class="link_view" title="阅读人数">{$articleInfo.view_num}人阅读</span>
            <span class="link_comments" title="评论">评论({$articleInfo.comment_num})</span>
          </div>
          <div class="margin_bottom_15"></div>
        </div>
      </div>
    </div>
    <div class="clr"></div>
    
    <form id="commentForm" method="post" action="__APP__/Public/formCheckVerifyCode">
    <input type="hidden" name="formId" value="verifyCode" />
    <input type="hidden" name="articleId" value="{$articleInfo.article_id}" />
    <div id="comment_section">
    	<div class="comment_header">发布评论</div>
    		<div class="row">
    		<input type="text" id="" class="validate[required,maxSize[8]] text-input" name="author" value="" />（昵称）
    		</div>
    		<div class="row">
    		<input type="text" id="verifyCode" style="vertical-align:middle;" class="validate[required,minSize[4],maxSize[4],ajax[ajaxVerifyCallPhp]] text-input" name="verifyCode" value="" /><img onclick="this.src='__APP__/Public/verify?i='+Math.random()" src="__APP__/Public/verify/" style="vertical-align:middle;" />
    		</div>
    		<div class="row">
    		<textarea class="validate[required,maxSize[300]] text-input comment_textarea" name="content"></textarea>
    		</div>
    		<a href="javascript:void(0);" id="cmt_submit" class="btn"><span class="btn_in">提交</span></a>
    </div>
    </form>
    <div id="comment_section">
    <div id="list_section">
    	<div class="comment_header">评论列表</div>
        <div class="cmt_list">
        <foreach name="comment" item="comment">
        	<div class="cmt_item">
            <div class="cmt-content-box">
            <div class="cmt_content_detail">
            	<span>{$comment.author}</span>{$comment.content}
            </div>
            <div class="cmt_pub_time">{$comment.comment_time}</div>
            </div>
            </div>
        </foreach>
        <div class="wp-pagenavi-2">{$page}</div>
        </div>
    </div>
    </div>
 </div>
 <!--/centercol -->
<include file="Common:article_righter" />
<div class="clr"></div>
</div>
<include file="Common:footer" />
<js href="__PUBLIC__/Script/Validator/ValidationEngine.min.js" />
<import file="Script.Validator.languages.validationEngine-zh_CN,Ueditor.third-party.SyntaxHighlighter.shCore" />
<script>
// Called once the server replies to the ajax form validation request
function ajaxValidationCallback(status, form, json, options){
	if (window.console) 
	console.log(status);
		
	if (status === true) {
		form.attr('action','__APP__/Article/comment');
		// uncomment these lines to submit the form to form.action
		form.validationEngine('detach');
		form.submit();
		// or you may use AJAX again to submit the data
	}
}
jQuery(document).ready(function(){
	search.init();
	SyntaxHighlighter.all();
	// binds form submission and fields to the validation engine
	jQuery("#commentForm").validationEngine({
		//promptPosition: "bottomLeft",
		
		ajaxFormValidation: true,
		ajaxFormValidationMethod: 'post',
		onAjaxFormComplete: ajaxValidationCallback
	});
	$("#cmt_submit").click(function(){
		$("#commentForm").submit();
	});
});

</script>